$(function () {
    $('#register-click').click(function () {
    var username = $('#username1').val();
    var password = $('#password1').val();
    var name = $('#name').val();
    var email = $('#email').val();
    $.post('/user/regist_user/',{'username':username,'password':password,'name':name,'email':email,},function (data, status) {
        var jsonObj = JSON.parse(data);
        var code = 0;
        code = jsonObj['code'];
        if(code==-1){
            $('.tip1').text(jsonObj['text']);
        }
        else{
            $('.tip1').text('注册成功');
        }
    })
});
    $('#login-click').click(function () {
    var username = $('#username').val();
    var password = $('#password').val();
    $.post('/user/login_user/',{'username':username,'password':password},function (data, status) {
        var jsonObj = JSON.parse(data);
        var code = 0;
        code = jsonObj['code'];
        if(code==-1){
            $('.tip').text(jsonObj['text']);
        }
        else{
            window.location.href = $('#url').text();
        }
    })
})
});